<?php


namespace app\common\Cache;


use app\admin\model\HomePage;
use app\common\CacheKey;

class HomePageCache
{
    /**
     * 获取启动页
     */
    public static function getPage()
    {
        $key = CacheKey::HOME_PAGE;
        $page = json_decode(redis()->get($key), true);
        if (empty($page) || $page == 'null') {
            $page = HomePage::getInstance()->getList(['status' => 1], 'img_url,outer_url', 'sort');
            redis(2)->set($key, json_encode($page), 86400);
        }
        return $page;
    }

    /**
     * 清除缓存
     */
    public static function delHomePageCache()
    {
        $key = CacheKey::HOME_PAGE;
        redis(2)->del($key);
    }
}